// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.util;

public final class LocationRNG {
    public static final LocationRNG instance = new LocationRNG();
    private static final float INT_TO_FLOAT = Float.intBitsToFloat(864026624);
    private long _s0;
    private long _s1;
    private long state;

    public void setSeed(long seed) {
        this.state = seed;
        this._s0 = this.nextSplitMix64();
        this._s1 = this.nextSplitMix64();
    }

    public long getSeed() {
        return this.state;
    }

    private long nextSplitMix64() {
        long _long = this.state += -7046029254386353131L;
        _long = (_long ^ _long >>> 30) * -4658895280553007687L;
        _long = (_long ^ _long >>> 27) * -7723592293110705685L;
        return _long ^ _long >>> 31;
    }

    public float nextFloat() {
        return (float)(this.nextInt() >>> 8) * INT_TO_FLOAT;
    }

    private int nextInt() {
        long long0 = this._s0;
        long long1 = this._s1;
        long long2 = long0 + long1;
        long1 ^= long0;
        this._s0 = Long.rotateLeft(long0, 55) ^ long1 ^ long1 << 14;
        this._s1 = Long.rotateLeft(long1, 36);
        return (int)(long2 & -1L);
    }

    public int nextInt(int n) {
        long _long = (long)(this.nextInt() >>> 1);
        _long = _long * (long)n >> 31;
        return (int)_long;
    }

    public int nextInt(int n, int x, int y, int z) {
        this.setSeed((long)z << 16 | (long)y << 32 | (long)x);
        return this.nextInt(n);
    }
}
